﻿using System;
using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization;
using System.Xml.Serialization;

namespace Grundy.Message
{
    
    [DataContract]
    public class Feature
    {
        public bool Equals(Feature other)
        {
            if (ReferenceEquals(null, other)) return false;
            if (ReferenceEquals(this, other)) return true;
            return other.Id.Equals(Id);
        }

        public override bool Equals(object obj)
        {
            if (ReferenceEquals(null, obj)) return false;
            if (ReferenceEquals(this, obj)) return true;
            if (obj.GetType() != typeof (Feature)) return false;
            return Equals((Feature) obj);
        }

        public override int GetHashCode()
        {
            return Id.GetHashCode();
        }

        public static bool operator ==(Feature left, Feature right)
        {
            return Equals(left, right);
        }

        public static bool operator !=(Feature left, Feature right)
        {
            return !Equals(left, right);
        }
        
        [DataMember]
        public Guid Id { get; set; }

        [Required]
        [DataMember]
        public string Name { get; set; }
        
        
        [IgnoreDataMember]
        public virtual ProductsCollection Products { get; protected set; }
    }
}